package com.zhaojindong.ioc.component.register.second;

import lombok.extern.log4j.Log4j;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

/**
 * @description: Filter candidates using a given custom
 * @author: zhaojindong
 * @create: 2018-08-13 20:08:59
 **/
@Log4j
public class MyTypeFilter implements TypeFilter {
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {

        ClassMetadata classMetadata = metadataReader.getClassMetadata();
        String className = classMetadata.getClassName();
        log.info("custom type class name: " + className);
        if (className.contains("Service")) {
            return true;
        }
        return false;
    }
}